﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _06_委托练习
{
    public partial class Frm_SetSpeed : Form
    {
        public Frm_SetSpeed(int step,int interval,Action<bool> action)
        {
            InitializeComponent();
            //设置滑块的值
            this.trackBar1.Value = step;
            this.trackBar2.Value = interval;
            //设置文本
            this.label2.Text = step.ToString();
            this.label4.Text = interval.ToString();

            //滑块事件=> 滚动的时候
            this.trackBar1.Scroll += (sender, e) =>
            {
                //设置步长
                MainForm.SetStep(this.trackBar1.Value);
                //设置文本
                this.label2.Text = this.trackBar1.Value.ToString();
            };
            this.trackBar2.Scroll += (sender, e) =>
            {
                //设置间隔
                MainForm.SetIntenal(this.trackBar2.Value);
                //设置文本
                this.label4.Text = this.trackBar2.Value.ToString();
            };

            //关闭窗体-响应事件
            this.FormClosed += (sender, e) => action(true);

        }
    }
}
